\defmodule{PointSet}

This abstract class defines the basic methods
for accessing and manipulating point sets.
A point set can be represented as a two-dimensional array, whose element
$(i,j)$ contains $u_{i,j}$, the \emph{coordinate} $j$ of point $i$.
Each coordinate $u_{i,j}$ is assumed to be in the unit interval $[0,1]$.
% and can be accessed directly via the (abstract) method
% \method{getCoordinate}{}.
% (implemented in subclasses).
Whether the values 0 and 1 can occur may depend on the
actual implementation of the point set.

All points have the same number of coordinates (their \emph{dimension})
and this number can be queried by \method{getDimension}{}.
The number of points is queried by \method{getNumPoints}{}.
The points and coordinates are both numbered starting from 0
and their number can actually be infinite.

The \method{iterator}{} method provides a \emph{point set iterator}
which permits one to enumerate the points and their coordinates.
Several iterators over the same point set can coexist at any given time.
These iterators are instances of a hidden inner-class that implements
the \class{PointSetIterator} interface.
The default implementation of iterator provided here relies on
the method \method{getCoordinate}{} to access the coordinates directly.
However, this approach is rarely efficient.
Specialized implementations that dramatically improve the performance
are provided in subclasses of \class{PointSet}.
The \class{PointSetIterator}{} interface actually extends the
\class{RandomStream}{} interface, so that the
iterator can also be seen as a \class{RandomStream} and used wherever
such a stream is required for generating uniform random numbers.
This permits one to easily replace pseudorandom numbers by the
coordinates of a selected set of highly-uniform points, i.e.,
to replace Monte Carlo by quasi-Monte Carlo in a simulation program.

%%%%%%%%
\begin{comment}
The class also offers tools to manipulate a list of randomizations
that can be applied to this point set.
\pierre{So far, the general types of randomizations have been implemented
   as containers.  We may remove this concept of list. }
\richard{La nouvelle randomisation d'Adam rend l'ancienne liste de
 randomisations obsol\`ete: nous n'avons jamais utilis\'e l'ancienne version.}
\end{comment}
%%%%%%

This abstract class has only one abstract method:
\method{getCoordinate}{}.
Providing an implementation for this method is already sufficient
for the subclass to work.
However, in practically all cases, efficiency can be dramatically improved by
overwriting \method{iterator}{} to provide a custom iterator that does not
necessarily rely on \method{getCoordinate}{}.
In fact, direct use of \method{getCoordinate}{} to access the coordinates
is discouraged.
One should access the coordinates only via the iterators.

\begin{detailed}  %%%%%
The built-in range checks require some extra time and also
assumes that nobody ever uses negative indices (Java does not offer unsigned
integers).  If \method{getCoordinate}{} is not accessed directly by the user,
it may be implemented without range checks.
\end{detailed}  %%%

\bigskip\hrule\bigskip
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{code}
\begin{hide}
/*
 * Class:        PointSet
 * Description:  Base class of all point sets
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.hups;\begin{hide}

import java.util.NoSuchElementException;
import java.util.List;
import java.util.ArrayList;
import umontreal.iro.lecuyer.rng.RandomStream;
import umontreal.iro.lecuyer.util.Num;
import umontreal.iro.lecuyer.util.PrintfFormat;
\end{hide}

public abstract class PointSet \begin{hide} {

   // The maximum number of usable bits (binary digits).
   // Since Java has no unsigned type, the
   // 32nd bit cannot be used efficiently. This mainly affects digit
   // scrambling and bit vectors. This also limits the maximum number
   // of columns for the generating matrices of digital nets in base 2.
   protected static final int MAXBITS = 31;
   // To avoid 0 for nextCoordinate when random shifting 
   protected double EpsilonHalf = 1.0 / Num.TWOEXP[55];  // 1/2^55

   protected int dim = 0;
   protected int numPoints = 0;
   protected int dimShift = 0;            // Current dimension of the shift.
   protected int capacityShift = 0;       // Number of array elements of shift;
                                          // it is always >= dimShift
   protected RandomStream shiftStream;    // Used to generate random shifts.
\end{hide}
\end{code}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Methods}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Sizes
\begin{code}

   public int getDimension()\begin{hide} {
      return dim;
   }\end{hide}
\end{code}
 \begin{tabb}
   Returns the dimension (number of available coordinates) of the point set.
   If the dimension is actually infinite, \texttt{Integer.MAX\_VALUE} is returned.
 \end{tabb}
\begin{htmlonly}
   \return{the dimension of the point set or \texttt{Integer.MAX\_VALUE}
   if it is infinite}
\end{htmlonly}
\begin{code}

   public int getNumPoints()\begin{hide} {
      return numPoints;
   }\end{hide}
\end{code}
 \begin{tabb}
   Returns the number of points.
   If this number is actually infinite, \texttt{Integer.MAX\_VALUE} is returned.
 \end{tabb}
\begin{htmlonly}
   \return{the number of points in the point set or \texttt{Integer.MAX\_VALUE}
   if the point set has an infinity of points.
\end{htmlonly}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Coordinates
\begin{code}

   public abstract double getCoordinate (int i, int j);
\end{code}
 \begin{tabb}
   Returns $u_{i,j}$, the coordinate $j$ of the point $i$.
\richard{La m\'ethode \texttt{getCoordinate} de certaines classes ne tient
pas compte du random shift, contrairement \`a l'it\'erateur de la m\^eme classe.
Faut-il que toutes les  \texttt{getCoordinate} impl\'ementent le random shift
quand il existe?}
 \end{tabb}
\begin{htmlonly}
   \param{i}{index of the point to look for}
   \param{j}{index of the coordinate to look for}
   \return{the value of $u_{i,j}$}
\end{htmlonly}
\begin{code}

   public PointSetIterator iterator()\begin{hide} {
      return new DefaultPointSetIterator();
   }\end{hide}
\end{code}
\begin{tabb}
 Constructs and returns a point set iterator.
 The default implementation returns an iterator that uses the method
 \method{getCoordinate}{}~\texttt{(i,j)} to iterate over the
 points and coordinates, but subclasses can reimplement it
 for better efficiency.
\end{tabb}
\begin{htmlonly}
   \return{point set iterator for the point set}
\end{htmlonly}
\begin{code}

   public void setStream (RandomStream stream)\begin{hide} {
      shiftStream = stream;
  }\end{hide}
\end{code}
 \begin{tabb}
   Sets the random stream used to generate random shifts to \texttt{stream}.
 \end{tabb}
\begin{htmlonly}
   \param{stream}{the new random stream}
\end{htmlonly}
\begin{code}

   public RandomStream getStream()\begin{hide} {
      return shiftStream;
  }\end{hide}
\end{code}
 \begin{tabb}
   Returns the random stream used to generate random shifts.
 \end{tabb}
\begin{htmlonly}
   \return{the random stream used}
\end{htmlonly}
\begin{code}

   public void randomize (PointSetRandomization rand) \begin{hide} {
       rand.randomize(this);
   }\end{hide}
\end{code}
\begin{tabb}
   Randomizes the point set using the given \texttt{rand}.
\end{tabb}
\begin{htmlonly}
   \param{rand}{\class{PointSetRandomization} to use}
\end{htmlonly}
\begin{code}

   public void addRandomShift (int d1, int d2, RandomStream stream)\begin{hide} {
//   throw new UnsupportedOperationException
//         ("addRandomShift in PointSet called");
     System.out.println (
        "******* WARNING:  addRandomShift in PointSet does nothing");
   }\end{hide}
\end{code}
\begin{tabb}  This method does nothing for this generic class.
  In some subclasses, it adds a random shift to all the points
  of the point set, using stream \texttt{stream} to generate the random numbers,
  for coordinates \texttt{d1} to \texttt{d2-1}.
\end{tabb}
\begin{code}

   public void addRandomShift (RandomStream stream)\begin{hide} {
      addRandomShift (0, dimShift, stream);
  }\end{hide}
\end{code}
\begin{tabb}  This method does nothing for this generic class.
 Similar to \texttt{addRandomShift (0, d2, stream)},
  with \texttt{d2} the dimension of the current random shift.
\end{tabb}
\begin{hide}\begin{code}

   @Deprecated
   public void addRandomShift (int d1, int d2) {
      addRandomShift (d1, d2, shiftStream);
  }
\end{code}
\begin{tabb} Similar to \texttt{addRandomShift(d1, d2, stream)}, with
  the current random stream.% This method does nothing for this generic class.
\end{tabb}
\begin{code}

   @Deprecated
   public void addRandomShift () {
      addRandomShift (0, dimShift, shiftStream);
   }
\end{code}
\begin{tabb} Similar to \texttt{addRandomShift(0, d2, stream)}
   with  the current random stream and \texttt{d2} the dimension of the current
  random shift.%  This method does nothing for this generic class.
\end{tabb}\end{hide}
\begin{code}

   public void clearRandomShift()\begin{hide} {
      capacityShift = 0;
      dimShift = 0;
//      shiftStream = null;
  }\end{hide}
\end{code}
\begin{tabb}
   Erases the current random shift, if any.
\end{tabb}
\begin{code}

   public void randomize (int d1, int d2, RandomStream stream)\begin{hide} {
      addRandomShift (d1, d2, stream);
   }\end{hide}
\end{code}
\begin{tabb} By default, this method simply calls
  \texttt{addRandomShift(d1, d2, stream)}.
\end{tabb}
\begin{code}

   public void randomize (RandomStream stream)\begin{hide} {
      addRandomShift (stream);
  }\end{hide}
\end{code}
\begin{tabb} By default, this method simply calls
   \texttt{addRandomShift(stream)}.
\end{tabb}
\begin{hide}\begin{code}

   @Deprecated
   public void randomize (int d1, int d2) {
      addRandomShift (d1, d2);
  }
\end{code}
\begin{tabb} By default, this method simply calls \texttt{addRandomShift(d1, d2)}.
\end{tabb}
\begin{code}

   @Deprecated
   public void randomize () {
      addRandomShift();
   }
\end{code}
\begin{tabb} By default, this method simply calls \texttt{addRandomShift()}.
\end{tabb}
\end{hide}\begin{code}

   public void unrandomize()\begin{hide} {
      clearRandomShift();
  }\end{hide}
\end{code}
\begin{tabb} By default, this method simply calls
   \texttt{clearRandomShift()}.
\end{tabb}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{code}

   public String toString() \begin{hide} {
       StringBuffer sb = new StringBuffer ("Number of points: ");
       int x = getNumPoints();
       if (x == Integer.MAX_VALUE)
          sb.append ("infinite");
       else
          sb.append (x);
       sb.append (PrintfFormat.NEWLINE + "Point set dimension: ");
       x = getDimension();
       if (x == Integer.MAX_VALUE)
          sb.append ("infinite");
       else
          sb.append (x);
       return sb.toString();
   }\end{hide}
\end{code}
\begin{tabb}
   Formats a string that contains information about the point set.
\end{tabb}
\begin{htmlonly}
   \return{string representation of the point set information}
\end{htmlonly}
\begin{code}

   public String formatPoints() \begin{hide} {
      PointSetIterator iter = iterator();
      return formatPoints (iter);
   }\end{hide}
\end{code}
\begin{tabb}
   Same as invoking \method{formatPoints}{int,int}\texttt{(n, d)} with $n$ and $d$ equal to the
   number of points and the dimension of this object, respectively.
\end{tabb}
\begin{htmlonly}
   \return{string representation of all the points in the point set}
   \exception{UnsupportedOperationException}{if the number of points
      or dimension of the point set is infinite}
\end{htmlonly}
\begin{code}

   public String formatPoints (int n, int d) \begin{hide} {
      PointSetIterator iter = iterator();
      return formatPoints (iter, n, d);
   }\end{hide}
\end{code}
\begin{tabb}
   Formats a string that displays the same information as returned by
  \method{toString}{}, together with the first $d$ coordinates of the
   first $n$ points. If $n$ is larger than the number of points in the point
  set, it is reset to that number. If $d$ is larger than the dimension of the
 points, it is reset to that dimension. The points are printed in the
  simplest format, separated by spaces,  by calling the default iterator
   repeatedly.
 %  \hpierre{Could perhaps just print what exists.}
\end{tabb}
\begin{htmlonly}
   \param{n}{number of points}
   \param{d}{dimension}
   \return{string representation of first d coordinates of first n points
      in the point set}
\end{htmlonly}
\begin{code}

   public String formatPoints (PointSetIterator iter) \begin{hide} {
      int n = getNumPoints();
      if (n == Integer.MAX_VALUE)
         throw new UnsupportedOperationException (
            "Number of points is infinite");
      int d = getDimension();
      if (d == Integer.MAX_VALUE)
         throw new UnsupportedOperationException ("Dimension is infinite");
      return formatPoints (iter, n, d);
   }\end{hide}
\end{code}
\begin{tabb}
    Same as invoking \method{formatPoints}{PointSetIterator,int,int}\texttt{(iter, n, d)}
    with $n$ and $d$ equal to the number of points and the dimension, respectively.
\end{tabb}
\begin{htmlonly}
  \param{iter}{iterator associated to the point set}
   \return{string representation of all the points in the point set}
   \exception{UnsupportedOperationException}{if the number of points
      or dimension of the point set is infinite}
\end{htmlonly}
\begin{code}

   public String formatPoints (PointSetIterator iter, int n, int d) \begin{hide} {
      if (getNumPoints() < n)
         n = getNumPoints();
      if (getDimension() < d)
         d = getDimension();
      StringBuffer sb = new StringBuffer (toString());
      sb.append (PrintfFormat.NEWLINE + PrintfFormat.NEWLINE
                 + "Points of the point set:" + PrintfFormat.NEWLINE);
      for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            sb.append ("  ");
            sb.append (iter.nextCoordinate());
         }
         sb.append (PrintfFormat.NEWLINE);
         iter.resetToNextPoint();
      }
      return sb.toString();
   }\end{hide}
\end{code}
\begin{tabb}
  Same as invoking \method{formatPoints}{int,int}\texttt{(n, d)}, but
   prints the points  by calling \texttt{iter} repeatedly. The order of
   the printed points may be different than the one resulting from the
  default iterator.
\end{tabb}
\begin{htmlonly}
  \param{iter}{iterator associated to the point set}
  \param{n}{number of points}
  \param{d}{dimension}
  \return{string representation of first d coordinates of first n points
      in the point set}
\end{htmlonly}
\begin{code}

   public String formatPointsBase (int b) \begin{hide} {
      PointSetIterator iter = iterator();
      return formatPointsBase (iter, b);
   }\end{hide}
\end{code}
\begin{tabb}
Similar to \method{formatPoints}{}\texttt{()}, but the
points coordinates are printed in base $b$.
\end{tabb}
\begin{htmlonly}
  \param{b}{base}
   \return{string representation of all the points in the point set}
   \exception{UnsupportedOperationException}{if the number of points
      or dimension of the point set is infinite}
\end{htmlonly}
\begin{code}

   public String formatPointsBase (int n, int d, int b) \begin{hide} {
      PointSetIterator iter = iterator();
      return formatPointsBase(iter, n, d, b);
   }\end{hide}
\end{code}
\begin{tabb}
Similar to \method{formatPoints}{int,int}\texttt{(n, d)}, but the
 points coordinates are printed in base $b$.
\end{tabb}
\begin{htmlonly}
   \param{n}{number of points}
   \param{d}{dimension}
   \param{b}{base}
   \return{string representation of first d coordinates of first n points
      in the point set}
\end{htmlonly}
\begin{code}

   public String formatPointsBase (PointSetIterator iter, int b) \begin{hide} {
      int n = getNumPoints();
      if (n == Integer.MAX_VALUE)
         throw new UnsupportedOperationException (
            "Number of points is infinite");
      int d = getDimension();
      if (d == Integer.MAX_VALUE)
         throw new UnsupportedOperationException ("Dimension is infinite");
      return formatPointsBase (iter, n, d, b);
   }\end{hide}
\end{code}
\begin{tabb}
Similar to
\method{formatPoints}{PointSetIterator}\texttt{(iter)},
but the points coordinates are printed in base $b$.
\end{tabb}
\begin{htmlonly}
  \param{iter}{iterator associated to the point set}
   \param{b}{base}
   \return{string representation of all the points in the point set}
   \exception{UnsupportedOperationException}{if the number of points
      or dimension of the point set is infinite}
\end{htmlonly}
\begin{code}

   public String formatPointsBase (PointSetIterator iter, int n, int d, int b) \begin{hide} {
      if (getNumPoints() < n)
         n = getNumPoints();
      if (getDimension() < d)
         d = getDimension();
      StringBuffer sb = new StringBuffer (toString());
      sb.append (PrintfFormat.NEWLINE + PrintfFormat.NEWLINE
                 + "Points of the point set:" + PrintfFormat.NEWLINE);
      double x;
      int acc = 10;
      if (b == 2)
         acc = 20;
      else if (b == 3)
         acc = 13;
      else
         acc = 10;
      if (null != shiftStream)
         acc += 6;
      int width = acc + 3;
      String chaine;
      for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            sb.append ("  ");
            x = iter.nextCoordinate();
            chaine = PrintfFormat.formatBase (-width, acc, b, x);
            sb.append (chaine);
         }
         sb.append (PrintfFormat.NEWLINE);
         iter.resetToNextPoint();
      }
      return sb.toString();
   }\end{hide}
\end{code}
\begin{tabb}
Similar to
\method{formatPoints}{PointSetIterator,int,int}\texttt{(iter, n, d)},
but the points coordinates are printed in base $b$.
\end{tabb}
\begin{htmlonly}
  \param{iter}{iterator associated to the point set}
  \param{n}{number of points}
  \param{d}{dimension}
  \param{b}{base}
  \return{string representation of first d coordinates of first n points
      in the point set}
\end{htmlonly}
\begin{code}

   public String formatPointsNumbered() \begin{hide} {
      int n = getNumPoints();
      if (n == Integer.MAX_VALUE)
         throw new UnsupportedOperationException (
            "Number of points is infinite");
      int d = getDimension();
      if (d == Integer.MAX_VALUE)
         throw new UnsupportedOperationException ("Dimension is infinite");
      return formatPointsNumbered (n, d);
   }\end{hide}
\end{code}
\begin{tabb}
 Same as invoking \method{formatPointsNumbered}{int,int}{\texttt{(n, d)}}
  with $n$ and $d$ equal to the number of points and the dimension,
   respectively.
\end{tabb}
\begin{htmlonly}
   \return{string representation of all the points in the point set}
   \exception{UnsupportedOperationException}{if the number of points
      or dimension of the point set is infinite}
\end{htmlonly}
\begin{code}

   public String formatPointsNumbered (int n, int d) \begin{hide} {
      if (getNumPoints() < n)
         n = getNumPoints();
      if (getDimension() < d)
         d = getDimension();
      StringBuffer sb = new StringBuffer (toString());
      PointSetIterator itr = iterator();
      sb.append (PrintfFormat.NEWLINE + PrintfFormat.NEWLINE
                 + "Points of the point set:");
      for (int i=0; i<n; i++) {
         sb.append (PrintfFormat.NEWLINE + "Point " +
    //                itr.getCurPointIndex() + " = (");
                                           i + "  =  (");
         boolean first = true;
         for (int j=0; j<d; j++) {
            if (first)
               first = false;
            else
               sb.append (", ");
            sb.append (itr.nextCoordinate());
         }
         sb.append (")");
         itr.resetToNextPoint();
      }
      return sb.toString();
   }\end{hide}
\end{code}
\begin{tabb}
   Same as invoking \method{formatPoints}{int,int}{\texttt{(n,d)}}, except that the points are numbered.
\end{tabb}
\begin{htmlonly}
  \param{n}{number of points}
  \param{d}{dimension}
  \return{string representation of first d coordinates of first n points
      in the point set}
\end{htmlonly}

\begin{code}\begin{hide}


// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// This class implements a default point set iterator.
// Since it is inherited by subclasses, it can be used as a base class
// for iterators.
// It is implemented as an inner class because it can then use directly
// the variables of the PointSet class.  It would be more difficult and
// cumbersome to access those variables if it was implemented as a
// separate class.

   protected class DefaultPointSetIterator implements PointSetIterator {

      protected int curPointIndex = 0;      // Index of the current point.
      protected int curCoordIndex = 0;      // Index of the current coordinate.
      protected double EpsilonHalf = 1.0 / Num.TWOEXP[55];
   // protected double EpsilonHalf = PointSet.this.EpsilonHalf;

      protected void outOfBounds () {
         if (getCurPointIndex() >= numPoints)
            throw new NoSuchElementException ("Not enough points available");
         else
            throw new NoSuchElementException ("Not enough coordinates available");
      }

      public void setCurCoordIndex (int j) {
         curCoordIndex = j;
      }

      public void resetCurCoordIndex() {
         setCurCoordIndex (0);
      }

      public int getCurCoordIndex() {
        return curCoordIndex;
      }

      public boolean hasNextCoordinate() {
        return getCurCoordIndex() < getDimension();
      }

      public double nextCoordinate() {
         if (getCurPointIndex() >= numPoints || getCurCoordIndex() >= dim)
            outOfBounds();
         return getCoordinate (curPointIndex, curCoordIndex++);
      }

      public void nextCoordinates (double p[], int d)  {
         if (getCurCoordIndex() + d > getDimension()) outOfBounds();
         for (int j = 0; j < d; j++)
            p[j] = nextCoordinate();
      }

      // This is called with i = numPoints when nextPoint generates the
      // last point, so i = numPoints must be allowed.
      // The "no more point" error will be raised if we ask for
      // a new coordinate or point.
      public void setCurPointIndex (int i) {
         curPointIndex = i;
         resetCurCoordIndex();
      }

      public void resetCurPointIndex() {
         setCurPointIndex (0);
      }

      public int resetToNextPoint() {
         setCurPointIndex (curPointIndex + 1);
         return curPointIndex;
      }

      public int getCurPointIndex() {
        return curPointIndex;
      }

      public boolean hasNextPoint() {
        return getCurPointIndex() < getNumPoints();
      }

      public int nextPoint (double p[], int d) {
         resetCurCoordIndex();
         nextCoordinates (p, d);
         return resetToNextPoint();
      }


      public void resetStartStream() {     // Same as resetCurPointIndex();
         resetCurPointIndex();
      }

      public void resetStartSubstream() {  // Same as resetCurCoordIndex();
         resetCurCoordIndex();
      }

      public void resetNextSubstream() {   // Same as resetToNextPoint();
         resetToNextPoint();
      }

      public void setAntithetic (boolean b) {
         throw new UnsupportedOperationException();
      }

      public double nextDouble() {          // Same as nextCoordinate();
         return nextCoordinate();
      }

      public void nextArrayOfDouble (double[] u, int start, int n) {
         if (n < 0)
            throw new IllegalArgumentException ("n must be positive.");
         for (int i = start; i < start+n; i++)
            u[i] = nextDouble();
      }

      public int nextInt (int i, int j) {
         return (i + (int)(nextDouble() * (j - i + 1.0)));
      }

      public void nextArrayOfInt (int i, int j, int[] u, int start, int n) {
         if (n < 0)
            throw new IllegalArgumentException ("n must be positive.");
         for (int k = start; k < start+n; k++)
            u[k] = nextInt (i, j);
      }

      public String formatState() {
         return "Current point index: " + getCurPointIndex() +
              PrintfFormat.NEWLINE + "Current coordinate index: " +
                  getCurCoordIndex();
      }
   }
}\end{hide}
\end{code}
